/*
 * LoadSheddingProfiler.cc
 *
 *  Created on: 2011-04-16
 *      Author: awjastrzebski
 */

#include "LoadSheddingProfiler.h"

Define_Module(LoadSheddingProfiler)

void LoadSheddingProfiler::initialize()
{
	AbstractProfiler::initialize();

	criticalBandwidth = par("criticalBandwidth");
}

bool LoadSheddingProfiler::acceptPacket(NetPacket* packet, simtime_t& delay)
{
	if(outputBandwidth < criticalBandwidth)
	{
		if(simTime() < endTime || endTime == 0)
			outputBandwidth += packet->getByteLength();

		return true;
	}
	else
	{
		delay = bandwidthCalcTick;
		return false;
	}
}
